package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ChannelPageReqDto;
import com.heima.model.common.dtos.ResponseResult;

import com.heima.model.common.pojos.wemedia.WmChannel;
import com.heima.wemedia.service.ChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Slf4j
public class ChannelController {
    @Autowired
    private ChannelService channelService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelPageReqDto dto){
        log.info("查询频道列表：{}",dto);
        return channelService.pageQuery(dto);
    }
    @PostMapping("save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        log.info("新增频道：{}",wmChannel);
        return channelService.saveChannel(wmChannel);
    }
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel){
        log.info("修改频道：{}",wmChannel);
        return channelService.updateChannel(wmChannel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        log.info("删除频道：{}",id);
        return channelService.deleteChannel(id);
    }


}
